# 父镜像
FROM centos

# 将工作目录设置为 /app
WORKDIR /app

# 将当前目录内容复制到位于 /app 中的容器中
ADD ./app/requirements.txt /app/requirements.txt

RUN yum update -y

# 安装依赖
RUN yum install -y wget
RUN yum install -y gcc automake autoconf libtool make
RUN yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel zlib-devel

# python3中，使用requests-html，须安装：
RUN yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y
RUN yum install nss xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

RUN wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
RUN tar -zxvf Python-3.6.4.tgz && cd Python-3.6.4/ && ./configure --prefix=/usr/local/ && make && make install
RUN ln -s /usr/local/bin/python3.6 /usr/bin/python
RUN ln -s /usr/local/bin/pip3.6 /usr/bin/pip

# 清除残留文件
RUN rm -fr Python-3.6.4  Python-3.6.4.tgz

# 安装 requirements.txt 中指定的任何所需软件包
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 使端口 80 可供此容器外的环境使用
EXPOSE 80

# 在容器启动时运行 run.py
CMD /bin/bash
# CMD python run.py
#CMD gunicorn -b 0.0.0.0:80 -w 1 -k gevent run:app

